package ru.padre386.geo_utils.data_loaders.gpx.domain;

import ru.padre386.geo_utils.data_loaders.common.IGeoPoint;
import ru.padre386.geo_utils.data_loaders.common.IGeoTrack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: indrdb
 * Date: 04.02.2011
 * Time: 14:24:50
 */
public class GpxTrack implements IGeoTrack {
    String name;
    List<GpxSegment> segments;

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<GpxSegment> getSegments() {
        return segments;
    }

    public void setSegments(List<GpxSegment> segments) {
        this.segments = segments;
    }

    public void addSegment(GpxSegment segment) {
        if (segments == null) {
            segments = new ArrayList<GpxSegment>();
        }
        segments.add(segment);
    }

    @Override
    public List<IGeoPoint> getPoints() {
        ArrayList<IGeoPoint> points = new ArrayList<IGeoPoint>();
        for (GpxSegment segment : segments) {
            points.addAll(segment.getPoints());
        }

        return points;
    }
}
